#include "rclcpp/rclcpp.hpp"
#include "custom_srv_msg/msg/custom_msg.hpp"


using std::placeholders::_1;

namespace custom_msg
{
    class custom_msg_sub :public rclcpp::Node
    {
    private:
        rclcpp::Subscription<custom_srv_msg::msg::CustomMsg>::SharedPtr sub_;
        void Sub_cb(const custom_srv_msg::msg::CustomMsg & Cus_msg)
        {
            RCLCPP_INFO(this->get_logger(),std::to_string(Cus_msg.i_a).c_str());
            RCLCPP_INFO(this->get_logger(),Cus_msg.str_b.c_str());
        }
    public:
        custom_msg_sub(/* args */);
        ~custom_msg_sub();
    };
    
    custom_msg_sub::custom_msg_sub(/* args */) :Node("custom_msg_sub_node")
    {
        sub_ = this->create_subscription<custom_srv_msg::msg::CustomMsg>("custom_msg",10,std::bind(&custom_msg_sub::Sub_cb,this,_1));
    }
    
    custom_msg_sub::~custom_msg_sub()
    {
    }
    
} // namespace custom_msg_pub


int main(int argc, char const *argv[])
{
    rclcpp::init(argc,argv);
    auto node = std::make_shared<custom_msg::custom_msg_sub>();
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}
